#import "GGrapheur.h"

template <class G, class S, class A>
GGrapheur<G, S, A>::GGrapheur(string prefixG, string prefixS, string prefixA){
	this->prefixG = prefixG;
	this->prefixS = prefixS;
	this->prefixA = prefixA;
	this->g_graphe = new G(prefixG + "1");
}

template <class G, class S, class A>
GGrapheur<G, S, A>::~GGrapheur(){
	
}

template <class G, class S, class A>
void GGrapheur<G, S, A>::manip1(){
	GGraphe<Graphe, Sommet, Arete> * g1 = new Graphe("G 1");
	Graphe * g2 = new Graphe("G 2");
	GGraphe<Molecule, Atome, Liaison> * m1 = new Molecule("M 1");
	Molecule * m2 = new Molecule("M 2");
	
	cout<<"Graphe <: GGraphe<Graphe, Sommet, Arete>"<<endl;
	cout<<g1->toStringComplet()<<g2->toStringComplet()<<endl;
	cout<<"Molecule <: GGraphe<Molecule, Atome, Liaison>"<<endl;
	cout<<m1->toStringComplet()<<m2->toStringComplet()<<endl;
}

template <class G, class S, class A>
void GGrapheur<G, S, A>::manip2(){
	
	cout<<"Utilisation du self()"<<endl<<endl;
	g_graphe->newSommet(prefixS + "1");
	cout<<g_graphe->getSommet(0)->toStringComplet()<<endl<<endl;
	g_graphe->newSommet(prefixS+"2");
	cout<<g_graphe->getSommet(1)->toStringComplet()<<endl<<endl;
	g_graphe->newSommet(prefixS+"3");
	cout<<g_graphe->getSommet(2)->toStringComplet()<<endl<<endl;
	cout<<g_graphe->toStringComplet()<<endl<<endl<<endl;
}

template <class G, class S, class A>
void GGrapheur<G, S, A>::manip3(){
	cout<<"Utilisation du dynamic_cast<X *>(this)"<<endl<<endl;
	cout<<g_graphe->toStringComplet()<<endl<<endl;
	GSommet<G, S, A> * s = g_graphe->getSommet(0);
	s->deleteSommet();
	delete s;
	cout<<g_graphe->toStringComplet()<<endl<<endl;
}

template <class G, class S, class A>
void GGrapheur<G, S, A>::manip4(){
	cout<<"Utilisation du static_cat<X *>(this)"<<endl<<endl;
	cout<<g_graphe->toStringComplet()<<endl<<endl;
	g_graphe->newArete("_" + prefixA +"_", g_graphe->getSommet(0), g_graphe->getSommet(1));
	cout<<g_graphe->getArete(0)->toStringComplet()<<endl<<endl;
	cout<<g_graphe->toStringComplet()<<endl<<endl;
}

template <class G, class S, class A>
void GGrapheur<G, S, A>::manip5(){
	cout<<"Manipulation"<<endl<<endl;
	cout<<g_graphe->toStringComplet()<<endl<<endl;
	g_graphe->newSommet(prefixS + "4");
	g_graphe->newSommet(prefixS + "5");
	g_graphe->newSommet(prefixS + "6");
	g_graphe->newArete("_" + prefixA +"_", g_graphe->getSommet(0), g_graphe->getSommet(2));
	g_graphe->newArete("_" + prefixA +"_", g_graphe->getSommet(0), g_graphe->getSommet(3));
	g_graphe->newArete("_" + prefixA +"_", g_graphe->getSommet(1), g_graphe->getSommet(3));
	cout<<endl<<endl<<g_graphe->toStringComplet()<<endl<<endl;
	cout<<"Suppression d'un sommet"<<endl<<endl;
	GSommet<G, S, A> * s = g_graphe->getSommet(0);
	s->deleteSommet();
	cout<<g_graphe->toStringComplet()<<endl<<endl;
	
}
